/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.springtree.spectrum.orm.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ricardo
 */
@Entity
@Table(name = "command")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Command.findAll", query = "SELECT c FROM Command c"),
    @NamedQuery(name = "Command.findByCommandId", query = "SELECT c FROM Command c WHERE c.commandId = :commandId"),
    @NamedQuery(name = "Command.findByCommandName", query = "SELECT c FROM Command c WHERE c.commandName = :commandName")})
public class Command implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @SequenceGenerator(name="SEQ",sequenceName = "command_seq",allocationSize=1)  
    @GeneratedValue(strategy=GenerationType.IDENTITY, generator="SEQ") 
    @Basic(optional = false)
    @Column(name = "command_id")
    private Integer commandId;
    @Column(name = "command_name")
    private String commandName;
    @OneToMany(mappedBy = "commandId")
    private Collection<CommandRule> commandRuleCollection;

    public Command() {
    }

    public Command(Integer commandId) {
        this.commandId = commandId;
    }

    public Integer getCommandId() {
        return commandId;
    }

    public void setCommandId(Integer commandId) {
        this.commandId = commandId;
    }

    public String getCommandName() {
        return commandName;
    }

    public void setCommandName(String commandName) {
        this.commandName = commandName;
    }

    @XmlTransient
    public Collection<CommandRule> getCommandRuleCollection() {
        return commandRuleCollection;
    }

    public void setCommandRuleCollection(Collection<CommandRule> commandRuleCollection) {
        this.commandRuleCollection = commandRuleCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (commandId != null ? commandId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Command)) {
            return false;
        }
        Command other = (Command) object;
        if ((this.commandId == null && other.commandId != null) || (this.commandId != null && !this.commandId.equals(other.commandId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "co.springtree.spectrum.orm.entities.Command[ commandId=" + commandId + " ]";
    }
    
}
